package com.zhuiYun.project.api.ordersAfterSales.mapper;

import com.zhuiYun.project.api.ordersAfterSales.entity.OrdersRetreat;
import com.zhuiYun.project.common.mapper.BaseMapper;
import com.zhuiYun.project.util.pageUtil.PageRequest;
import org.apache.ibatis.annotations.Select;
import org.mapstruct.Mapper;

import java.util.Collection;
import java.util.List;

@Mapper
public interface ordersRetreatMapper extends BaseMapper<OrdersRetreat> {




    @Select("select id,order_number,user_id,order_type_id,status_id from orders where  del_flag=0")
    List<OrdersRetreat> getMyAllOrderAfterSales();


    @Select("SELECT r.id,r.orders_retreat_take_notes,a.orders_type,a.orders_cause,a.orders_describe,a.image_id,o.create_time,y.nick_name,o.order_number,o.order_type_id,s.status,cc.commodity_name,cctv.address_consignee,cctv.address_location_province,cctv.address_location_city,cctv.address_location_county,cctv.address_detailed\n" +
            "FROM orders_retreat r\n" +
            "LEFT JOIN orders_after_sales a\n" +
            "ON r.orders_after_sales_id = a.id\n" +
            "LEFT JOIN orders o\n" +
            "ON r.orders_id = o.id\n" +
            "LEFT JOIN orders_after_sales_status s\n" +
            "ON s.id = r.orders_status_id\n" +
            "LEFT JOIN commodity_order c\n" +
            "ON o.id = c.orders_id\n" +
            "LEFT JOIN user y\n" +
            "ON r.user_id = y.id\n" +
            "LEFT JOIN commodity cc\n" +
            "LEFT JOIN commodity cc\n" +
            "ON c.commodity_id = cc.id\n" +
            "LEFT JOIN user_address cctv\n" +
            "ON o.address_id = cctv.id\n" +
            "WHERE  o.order_type_id =1 and r.del_flag = 0 and r.orders_status_id = 2 or r.orders_status_id = 1 and r.orders_retreat_take_notes = 1 ")
    List<OrdersRetreat> getMyCommodityOrderAfterSales();


    @Select("SELECT r.id,r.orders_retreat_take_notes,a.orders_type,a.orders_cause,a.image_id,a.orders_describe,o.create_time,y.nick_name,o.order_number,o.order_type_id,s.status,cc.diy_name,cctv.address_consignee,cctv.address_location_province,cctv.address_location_city,cctv.address_location_county,cctv.address_detailed\n" +
            "FROM orders_retreat r\n" +
            "LEFT JOIN orders_after_sales a\n" +
            "ON r.orders_after_sales_id = a.id\n" +
            "LEFT JOIN orders o\n" +
            "ON r.orders_id = o.id\n" +
            "LEFT JOIN orders_after_sales_status s\n" +
            "ON s.id = r.orders_status_id\n" +
            "LEFT JOIN handwork_diy_order c\n" +
            "ON o.id = c.orders_id\n" +
            "LEFT JOIN use" +
            "r y\n" +
            "ON r.user_id = y.id\n" +
            "LEFT JOIN handwork_diy cc\n" +
            "ON c.diy_id = cc.id\n" +
            "LEFT JOIN user_address cctv\n" +
            "ON o.address_id = cctv.id\n" +
            "WHERE  o.order_type_id =2 and r.del_flag = 0 and r.orders_status_id = 2 or r.orders_status_id = 1 and r.orders_retreat_take_notes = 1 ")
    List<OrdersRetreat> getMyDiyOrderAfterSales();
}
